<?php
//ini_set ("display_errors", "On");
//session_start();
require '../inc.php';
if(!function_exists("imagecreatetruecolor"))
{
	$input = array('1335','3114','4922','2320','1268','9011');
	$input = $input[array_rand($input)];
	$_SESSION["check_auth_number"]= $input;
	header("Content-type: image/png");
	readfile("noGD/{$input}.png");
	exit();
}
$font = array('font/a.ttf','font/b.ttf','font/c.ttf');
//set widch height
$img_width=75;
$img_height=24;		
srand(microtime() * 100000);

$new_number=NULL;
for($ti=0;$ti<4;$ti++){
	$new_number.=dechex(rand(0,9));
}

$_SESSION["check_auth_number"]= $new_number;

$number_img=imagecreatetruecolor($img_width+10,$img_height);
$white = imagecolorallocate($number_img, 255, 255, 255);
imagefilledrectangle($number_img, 0, 0, $img_width+10-1, $img_height-1, $white);
for($i=1;$i<=100;$i++)
{
	imagefttext($number_img,mt_rand(5,10),mt_rand(0,60),mt_rand(1,$img_width),mt_rand(1,$img_height),imagecolorallocate($number_img,mt_rand(180,255),mt_rand(180,255),mt_rand(180,255)),$font[mt_rand(0,2)],"*");
}
for($i=1;$i<=100;$i++)
{
	imagefttext($number_img,mt_rand(5,10),mt_rand(0,180),mt_rand(1,$img_width),mt_rand(1,$img_height),imagecolorallocate($number_img,mt_rand(180,255),mt_rand(180,255),mt_rand(180,255)),$font[mt_rand(0,2)],"\\");
}
for($i=0;$i<strlen($_SESSION["check_auth_number"]);$i++)
{
	imagefttext($number_img,mt_rand(14,16),mt_rand(-30,30),$i*$img_width/4+mt_rand(5,15),mt_rand($img_height*4/5,$img_height*8/9),imageColorAllocate($number_img,mt_rand(0,100),mt_rand(0,150),mt_rand(0,200)),$font[mt_rand(0,2)],$_SESSION["check_auth_number"][$i]);
}
g::setcookie("idcode",authimg::en($_SESSION["check_auth_number"]));
header("Content-type: image/png");
imagepng($number_img);
imagedestroy($number_img);
?>